package start.spring.basic.flowable.config;

import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.engine.RuntimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

import start.spring.basic.flowable.listener.flowable.GlobalEventListener;

/**
 * flowable全局监听配置
 *
 * @author ssc
 */
@Configuration
public class GlobalEventListenerConfig implements ApplicationListener<ContextRefreshedEvent>  {


	@Autowired
	private GlobalEventListener globalEventListener;
	
	@Autowired
	private RuntimeService runtimeService;

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		// 流程正常结束
		runtimeService.addEventListener(globalEventListener, FlowableEngineEventType.PROCESS_COMPLETED);
	}
}
